home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / dalla rivista / host contacted / jikes.lha / jikes-1.11 / src / getclass.cpp < prev    next >
C/C++ Source or Header  |  2000-01-16  |  47KB  |  1,139 lines

  1. // $Id: getclass.cpp,v 1.16 1999/11/03 00:46:31 shields Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10. #include "config.h"
  11. #include <sys/stat.h>
  12. #include "control.h"
  13. #include "semantic.h"
  14. #include "access.h"
  15. #include "getclass.h"
  16. #include "zip.h"
  17.  
  18. inline u1 Semantic::GetU1(char *buffer)
  19. {
  20.     return *buffer;
  21. }
  22.  
  23. inline u2 Semantic::GetU2(char *buffer)
  24. {
  25.     u2 i = (u1) *buffer++;
  26.     return (i << 8) + (u1) *buffer;
  27. }
  28.  
  29. inline u4 Semantic::GetU4(char *buffer)
  30. {
  31.     u4 i = (u1) *buffer++;
  32.     i = (i << 8) + (u1) *buffer++;
  33.     i = (i << 8) + (u1) *buffer++;
  34.     return (i << 8) + (u1) *buffer;
  35. }
  36.  
  37. inline u1 Semantic::GetAndSkipU1(char *&buffer)
  38. {
  39.     return (u1) *buffer++;
  40. }
  41.  
  42. inline u2 Semantic::GetAndSkipU2(char *&buffer)
  43. {
  44.     u2 i = (u1) *buffer++;
  45.     return (i << 8) + (u1) *buffer++;
  46. }
  47.  
  48. inline u4 Semantic::GetAndSkipU4(char *&buffer)
  49. {
  50.     u4 i = (u1) *buffer++;
  51.     i = (i << 8) + (u1) *buffer++;
  52.     i = (i << 8) + (u1) *buffer++;
  53.     return (i << 8) + (u1) *buffer++;
  54. }
  55.  
  56. inline void Semantic::Skip(char *&buffer, int n)
  57. {
  58.     buffer += n;
  59. }
  60.  
  61.  
  62. TypeSymbol *Semantic::ProcessNestedType(TypeSymbol *base_type, NameSymbol *name_symbol, LexStream::TokenIndex tok)
  63. {
  64.     TypeSymbol *inner_type = base_type -> FindTypeSymbol(name_symbol);
  65.     if (! inner_type)
  66.     {
  67.         int length = base_type -> ExternalNameLength() + 1 + name_symbol -> NameLength(); // +1 for $,... +1 for $
  68.         wchar_t *external_name = new wchar_t[length + 1]; // +1 for '\0';
  69.         wcscpy(external_name, base_type -> ExternalName());
  70.         wcscat(external_name, StringConstant::US__DS);
  71.         wcscat(external_name, name_symbol -> Name());
  72.         NameSymbol *external_name_symbol = control.FindOrInsertName(external_name, length);
  73.  
  74.         delete [] external_name;
  75.  
  76.         inner_type = base_type -> InsertNestedTypeSymbol(name_symbol);
  77.         inner_type -> outermost_type = base_type -> outermost_type;
  78.         inner_type -> supertypes_closure = new SymbolSet;
  79.         inner_type -> subtypes = new SymbolSet;
  80.         inner_type -> SetExternalIdentity(external_name_symbol);
  81.         inner_type -> SetOwner(base_type);
  82.         inner_type -> SetSignature(control);
  83.  
  84.         FileSymbol *file_symbol = Control::GetFile(control, base_type -> ContainingPackage(), external_name_symbol);
  85.         if (file_symbol)
  86.         {
  87.             inner_type -> file_symbol = file_symbol;
  88.             inner_type -> SetLocation();
  89.  
  90.             ReadClassFile(inner_type, tok);
  91.         }
  92.         else
  93.         {
  94.             inner_type -> SetSymbolTable(1); // this symbol table will only contain a default constructor
  95.             inner_type -> super = control.Object();
  96.             inner_type -> MarkBad();
  97.             AddDefaultConstructor(inner_type);
  98.             ReportSemError(SemanticError::TYPE_NOT_FOUND,
  99.                            tok,
  100.                            tok,
  101.                            inner_type -> ContainingPackage() -> PackageName(),
  102.                            inner_type -> ExternalName());
  103.         }
  104.     }
  105.  
  106.     return inner_type;
  107. }
  108.  
  109.  
  110. TypeSymbol *Semantic::RetrieveNestedTypes(TypeSymbol *base_type, wchar_t *signature, LexStream::TokenIndex tok)
  111. {
  112.     int len;
  113.     for (len = 0; signature[len] != U_NULL && signature[len] != U_DOLLAR; len++)
  114.         ;
  115.     NameSymbol *name_symbol = control.FindOrInsertName(signature, len);
  116.     TypeSymbol *inner_type = ProcessNestedType(base_type, name_symbol, tok);
  117.  
  118.     return (signature[len] == U_DOLLAR ? RetrieveNestedTypes(inner_type, &signature[len + 1], tok) : inner_type);
  119. }
  120.  
  121.  
  122. TypeSymbol *Semantic::ReadTypeFromSignature(TypeSymbol *base_type, char *utf8_signature, int length, LexStream::TokenIndex tok)
  123. {
  124.     TypeSymbol *type = control.type_table.FindType(utf8_signature, length);
  125.  
  126.     if (type)
  127.     {
  128.         if (type -> SourcePending())
  129.             control.ProcessHeaders(type -> file_symbol);
  130.     }
  131.     else
  132.     {
  133.         wchar_t *signature = new wchar_t[length + 1];
  134.         (void) Control::ConvertUtf8ToUnicode(signature, utf8_signature, length);
  135.  
  136.         int total_length;
  137.         for (total_length = 0; signature[total_length] != U_NULL && signature[total_length] != U_DOLLAR; total_length++)
  138.             ;
  139.  
  140.         if (signature[total_length] != U_NULL && Code::IsDigit(signature[total_length + 1])) // an anonymous or a local type?
  141.         {
  142.             for (total_length += 2; Code::IsDigit(signature[total_length]); total_length++) // will stop at next '$' or '\0' !!!
  143.                 ;
  144.             if (signature[total_length] != U_NULL) // not an anonymous type ?  then, it's a local type: scan local name
  145.             {
  146.                 for (total_length++; signature[total_length] != U_NULL && signature[total_length] != U_DOLLAR; total_length++)
  147.                     ;
  148.             }
  149.         }
  150.  
  151.         int len;
  152.         for (len = total_length - 1; len >= 0 && signature[len] != U_SLASH; len--)
  153.             ;
  154.  
  155.         wchar_t *name = &(signature[len + 1]);
  156.  
  157.         //
  158.         // When a package name is specified in the signature, we look for the type in question
  159.         // in that package, i.e., we redefine package. Otherwise, we search for the type in the
  160.         // unnamed package.
  161.         //
  162.         PackageSymbol *package = NULL;
  163.  
  164.         //
  165.         // Which package?
  166.         //
  167.         if (len >= 0)
  168.         {
  169.             wchar_t *package_name = new wchar_t[len + 1];
  170.             for (int i = 0; i < len; i++)
  171.                 package_name[i] = signature[i];
  172.             package_name[len] = U_NULL;
  173.             package = control.ProcessPackage(package_name);
  174.  
  175.             if (package -> directory.Length() == 0)
  176.             {
  177.                 ReportSemError(SemanticError::PACKAGE_NOT_FOUND,
  178.                                tok,
  179.                                tok,
  180.                                package -> PackageName());
  181.             }
  182.             delete [] package_name;
  183.         }
  184.         else package = control.unnamed_package;
  185.  
  186.         //
  187.         // Process type
  188.         //
  189.         NameSymbol *name_symbol = control.FindOrInsertName(name, total_length - (len + 1));
  190.         type = package -> FindTypeSymbol(name_symbol);
  191.         if (type)
  192.         {
  193.             if (type -> SourcePending())
  194.                 control.ProcessHeaders(type -> file_symbol);
  195.         }
  196.         else
  197.         {
  198.             FileSymbol *file_symbol = Control::GetFile(control, package, name_symbol);
  199.  
  200.             //
  201.             // If we are dealing with the unnamed package, ...
  202.             //
  203.             if ((! file_symbol) && package == control.unnamed_package)
  204.                 file_symbol = Control::GetFile(control, control.unnamed_package, name_symbol);
  205.  
  206.             //
  207.             // If a file_symbol was not found, ReadType will issue an error message
  208.             //
  209.             type = ReadType(file_symbol, package, name_symbol, tok);
  210.  
  211.             //
  212.             // If we have to do a full check and we have a case where a ".class" file
  213.             // depends on a ".java" file then we should signal that the ".java" file
  214.             // associated with the ".class" file should be recompiled.
  215.             //
  216.             if (control.option.full_check && (! control.option.depend) &&
  217.                 file_symbol && file_symbol -> IsJava() && (! file_symbol -> IsZip()))
  218.             {
  219.                 control.recompilation_file_set.AddElement(file_symbol);
  220.                 if (! control.option.incremental && control.option.pedantic)
  221.                 {
  222.                     ReportSemError(SemanticError::RECOMPILATION,
  223.                                    tok,
  224.                                    tok,
  225.                                    base_type -> ContainingPackage() -> Name(),
  226.                                    base_type -> ExternalName(),
  227.                                    type -> ContainingPackage() -> Name(),
  228.                                    type -> ExternalName());
  229.                 }
  230.             }
  231.         }
  232.  
  233.         if (signature[total_length] == U_DOLLAR)
  234.             type = RetrieveNestedTypes(type, &signature[total_length + 1], tok);
  235.  
  236.         delete [] signature;
  237.     }
  238.  
  239.     //
  240.     // Establish a dependence from base_type (read from a class file) to type.
  241.     //
  242.     AddDependence(base_type, type, tok);
  243.  
  244.     return type;
  245. }
  246.  
  247.  
  248. TypeSymbol *Semantic::ProcessSignature(TypeSymbol *base_type, char *signature, LexStream::TokenIndex tok)
  249. {
  250.     TypeSymbol *type;
  251.     int num_dimensions = 0;
  252.  
  253.     for (; *signature == U_LEFT_BRACKET; signature++)
  254.         num_dimensions++;
  255.  
  256.     switch(*signature)
  257.     {
  258.         case U_B:
  259.              type = control.byte_type;
  260.              break;
  261.         case U_C:
  262.              type = control.char_type;
  263.              break;
  264.         case U_D:
  265.              type = control.double_type;
  266.              break;
  267.         case U_F:
  268.              type = control.float_type;
  269.              break;
  270.         case U_I:
  271.              type = control.int_type;
  272.              break;
  273.         case U_J:
  274.              type = control.long_type;
  275.              break;
  276.         case U_L:
  277.              {
  278.                  //
  279.                  // The signature is of the form: "L<filename>;" - So, +1 to skip the 'L'
  280.                  // ReadTypeFromSignature considers a semicolon to be a terminator.
  281.                  //
  282.                  char *str = ++signature;
  283.                  while (*str != U_SEMICOLON)
  284.                      str++;
  285.                  type = ReadTypeFromSignature(base_type, signature, str - signature, tok);
  286.              }
  287.              break;
  288.         case U_S:
  289.              type = control.short_type;
  290.              break;
  291.         case U_Z:
  292.              type = control.boolean_type;
  293.              break;
  294.         case U_V:
  295.              type = control.void_type;
  296.              break;
  297.         default:
  298.             assert(! "KNOW WHAT TO DO WITH SIGNATURE");
  299.             break;
  300.     }
  301.  
  302.     return (num_dimensions == 0 ? type : type -> GetArrayType((Semantic *)this, num_dimensions));
  303. }
  304.  
  305.  
  306. inline TypeSymbol *Semantic::GetClassPool(TypeSymbol *base_type,
  307.                                           TypeSymbol **class_pool,
  308.                                           char **constant_pool,
  309.                                           int index,
  310.                                           LexStream::TokenIndex tok)
  311. {
  312.     if (! class_pool[index])
  313.     {
  314.         u2 name_index = Constant_Class_info::NameIndex(constant_pool[index]);
  315.         char *str = Constant_Utf8_info::Bytes(constant_pool[name_index]);
  316.  
  317.         if (*str == U_LEFT_BRACKET)
  318.             class_pool[index] = ProcessSignature(base_type, str, tok);
  319.         else
  320.         {
  321.             u2 length = Constant_Utf8_info::Length(constant_pool[name_index]);
  322.             char *p;
  323.             for (p = &str[length - 1]; Code::IsDigit(*p); p--)
  324.                 ;
  325.             if (*p != U_DOLLAR) // not an anonymous class
  326.                 class_pool[index] = ReadTypeFromSignature(base_type, str, length, tok);
  327.         }
  328.     }
  329.  
  330.     return class_pool[index];
  331. }
  332.  
  333.  
  334. void Semantic::ReadClassFile(TypeSymbol *type, LexStream::TokenIndex tok)
  335. {
  336. #ifdef TEST
  337.     control.class_files_read++;
  338. #endif
  339.  
  340.     FileSymbol *file_symbol = type -> file_symbol;
  341.  
  342.     if (control.option.verbose)  {
  343.         Coutput << "[read "
  344.                 << file_symbol -> FileName()
  345.                 << "]\n";
  346.     }
  347.  
  348.     if (file_symbol -> IsZip())
  349.     {
  350.         ZipFile *zipfile = new ZipFile(file_symbol);
  351.  
  352.         if (zipfile -> Buffer() == NULL)
  353.         {
  354.             type -> SetSymbolTable(1); // this symbol table will only contain a default constructor
  355.             if (type != control.Object())
  356.                 type -> super = (type == control.Throwable() ? control.Object() : control.Throwable());
  357.             type -> MarkBad();
  358.             AddDefaultConstructor(type);
  359.  
  360.             ReportSemError(SemanticError::COMPRESSED_ZIP_FILE,
  361.                            tok,
  362.                            tok,
  363.                            file_symbol -> PathSym() -> Name(),
  364.                            type -> ContainingPackage() -> PackageName(),
  365.                            type -> ExternalName());
  366.         }
  367.         else if (! ProcessClassFile(type, zipfile -> Buffer(), file_symbol -> uncompressed_size, tok))
  368.             ProcessBadClass(type, tok);
  369.  
  370.         delete zipfile;
  371.     }
  372.     else
  373.     {
  374. #if defined(UNIX_FILE_SYSTEM) || defined(AMIGAOS_FILE_SYSTEM)
  375.         FILE *classfile = ::SystemFopen(file_symbol -> FileName(), "rb");
  376.         if (classfile == NULL)
  377.         {
  378.             type -> SetSymbolTable(1); // this symbol table will only contain a default constructor
  379.             if (type != control.Object())
  380.                 type -> super = (type == control.Throwable() ? control.Object() : control.Throwable());
  381.             type -> MarkBad();
  382.             AddDefaultConstructor(type);
  383.  
  384.             ReportSemError(SemanticError::CANNOT_OPEN_CLASS_FILE,
  385.                            tok,
  386.                            tok,
  387.                            type -> ContainingPackage() -> PackageName(),
  388.                            type -> ExternalName());
  389.         }
  390.         else
  391.         {
  392.             struct stat status;
  393.             ::SystemStat(file_symbol -> FileName(), &status);
  394.  
  395.             char *class_buffer = new char[status.st_size];
  396.             fread(class_buffer, sizeof(char), status.st_size, classfile);
  397.             fclose(classfile);
  398.  
  399.             if (! ProcessClassFile(type, class_buffer, status.st_size, tok))
  400.                 ProcessBadClass(type, tok);
  401.  
  402.             delete [] class_buffer;
  403.         }
  404. #elif defined(WIN32_FILE_SYSTEM)
  405.         HANDLE classfile = CreateFile(file_symbol -> FileName(), GENERIC_READ, FILE_SHARE_READ,
  406.                                       NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
  407.         HANDLE mapfile = (classfile == INVALID_HANDLE_VALUE
  408.                                      ? classfile
  409.                                      : CreateFileMapping(classfile, NULL, PAGE_READONLY, 0, 0, NULL));
  410.  
  411.         char *class_buffer = (mapfile == INVALID_HANDLE_VALUE ? NULL : (char *) MapViewOfFile(mapfile, FILE_MAP_READ, 0, 0, 0));
  412.  
  413.         if (class_buffer == NULL)
  414.         {
  415.             type -> SetSymbolTable(1); // this symbol table will only contain a default constructor
  416.             if (type != control.Object())
  417.                 type -> super = (type == control.Throwable() ? control.Object() : control.Throwable());
  418.             type -> MarkBad();
  419.             AddDefaultConstructor(type);
  420.  
  421.             ReportSemError(SemanticError::CANNOT_OPEN_CLASS_FILE,
  422.                            tok,
  423.                            tok,
  424.                            type -> ContainingPackage() -> PackageName(),
  425.                            type -> ExternalName());
  426.         }
  427.         else
  428.         {
  429.             DWORD high_order,
  430.                   size = GetFileSize(classfile, &high_order);
  431.  
  432.             size = (size == 0xFFFFFFFF && GetLastError() != NO_ERROR ? 0 : size);
  433.  
  434.             if (! ProcessClassFile(type, class_buffer, size, tok))
  435.                 ProcessBadClass(type, tok);
  436.  
  437.             UnmapViewOfFile(class_buffer);
  438.             CloseHandle(mapfile);
  439.             CloseHandle(classfile);
  440.         }
  441. #endif
  442.     }
  443.  
  444.     return;
  445. }
  446.  
  447.  
  448. void Semantic::ProcessBadClass(TypeSymbol *type, LexStream::TokenIndex tok)
  449. {
  450.     if (! type -> Table()) // if there is no symbol table, add one
  451.         type -> SetSymbolTable(1); // this symbol table will only contain a default constructor
  452.     if ((! type -> super) && type != control.Object()) // if there is no super type, add one
  453.         type -> super = (type == control.Throwable() ? control.Object() : control.Throwable());
  454.     type -> MarkBad();
  455.     if (! type -> FindConstructorSymbol()) // if there are no constructors, add a default one
  456.         AddDefaultConstructor(type);
  457.  
  458.     ReportSemError(SemanticError::INVALID_CLASS_FILE,
  459.                    tok,
  460.                    tok,
  461.                    type -> ContainingPackage() -> PackageName(),
  462.                    type -> ExternalName());
  463.  
  464.     return;
  465. }
  466.  
  467.  
  468. bool Semantic::ProcessClassFile(TypeSymbol *type, char *buffer, int buffer_size, LexStream::TokenIndex tok)
  469. {
  470.     char *buffer_tail = &buffer[buffer_size];
  471.  
  472.     type -> MarkHeaderProcessed();
  473.     type -> MarkConstructorMembersProcessed();
  474.     type -> MarkMethodMembersProcessed();
  475.     type -> MarkFieldMembersProcessed();
  476.     type -> MarkLocalClassProcessingCompleted();
  477.     type -> MarkSourceNoLongerPending();
  478.  
  479.     Skip(buffer, 8); // u4 magic;
  480.                      // u2 minor_version;
  481.                      // u2 major_version;
  482.  
  483.     if (! InRange(buffer, buffer_tail, 2))
  484.         return false;
  485.     u2 constant_pool_count = GetAndSkipU2(buffer);
  486.     char **constant_pool = new char*[constant_pool_count];
  487.     TypeSymbol **class_pool = (TypeSymbol **)
  488.                               memset(new TypeSymbol*[constant_pool_count], 0, constant_pool_count * sizeof(TypeSymbol *));
  489.  
  490.     constant_pool[0] = NULL;
  491.     int *next_pool_index = new int[constant_pool_count],
  492.         Class_root = 0,
  493.         NameAndType_root = 0;
  494.  
  495.     for (int i = 1; i < constant_pool_count; i++)
  496.     {
  497.         constant_pool[i] = buffer;
  498.         if (! InRange(buffer, buffer_tail, 1))
  499.             return false;
  500.         u1 tag = GetAndSkipU1(buffer);
  501.         if (tag == Cp_Info::CONSTANT_Long || tag == Cp_Info::CONSTANT_Double)
  502.             ++i; // skip the next entry for eight-byte constants
  503.  
  504.         u2 length;
  505.         switch(tag)
  506.         {
  507.             case Cp_Info::CONSTANT_Utf8:
  508.                  if (! InRange(buffer, buffer_tail, 2))
  509.                      return false;
  510.                  length = GetAndSkipU2(buffer);
  511.                  break;
  512.             case Cp_Info::CONSTANT_Class:
  513.                  length = 2;                      // set_NameIndex(GetU2(classfile));
  514.                  next_pool_index[i] = Class_root; // save index of class constant
  515.                  Class_root = i;
  516.                  break;
  517.             case Cp_Info::CONSTANT_String:
  518.                  length = 2; // set_NameIndex(GetU2(classfile));
  519.                  break;
  520.             case Cp_Info::CONSTANT_NameAndType:
  521.                  length = 4; // set_class_index(GetU2(classfile)); set_name_and_type_index(GetU2(classfile));
  522.                              //                                     or
  523.                              // set_NameIndex(GetU2(classfile)); set_DescriptorIndex(GetU2(classfile));
  524.                              //                                     or
  525.                              // SetBytes(GetU4(classfile));
  526.                  next_pool_index[i] = NameAndType_root; // save index of class constant
  527.                  NameAndType_root = i;
  528.                  break;
  529.             case Cp_Info::CONSTANT_Fieldref:
  530.             case Cp_Info::CONSTANT_Methodref:
  531.             case Cp_Info::CONSTANT_InterfaceMethodref:
  532.             case Cp_Info::CONSTANT_Integer:
  533.             case Cp_Info::CONSTANT_Float:
  534.                  length = 4; // set_class_index(GetU2(classfile)); set_name_and_type_index(GetU2(classfile));
  535.                              //                                     or
  536.                              // set_NameIndex(GetU2(classfile)); set_DescriptorIndex(GetU2(classfile));
  537.                              //                                     or
  538.                              // SetBytes(GetU4(classfile));
  539.                  break;
  540.             case Cp_Info::CONSTANT_Long:
  541.             case Cp_Info::CONSTANT_Double:
  542.                  length = 8; // set_HighBytes(GetU4(classfile));
  543.                              // set_LowBytes(GetU4(classfile));
  544.  
  545.                  break;
  546.             default:
  547. fprintf(stderr, "%s%d%s", "chaos: CODE \"", (int) tag, "\" is an invalid tag !!!\n");
  548. fflush(stderr);
  549.                  break;
  550.         }
  551.  
  552.         Skip(buffer, length);
  553.     }
  554.  
  555.     //
  556.     // We are now ready to process this class file. If type is a nested
  557.     // class, we will set its untransformed access flags properly later...
  558.     //
  559.     if (! InRange(buffer, buffer_tail, 2))
  560.         return false;
  561.     type -> SetFlags(GetAndSkipU2(buffer));
  562.  
  563.     if (! InRange(buffer, buffer_tail, 2))
  564.         return false;
  565.     u2 this_class_index = GetAndSkipU2(buffer); // The index of this class
  566.     u2 name_index = Constant_Class_info::NameIndex(constant_pool[this_class_index]);
  567.     char *type_name = Constant_Utf8_info::Bytes(constant_pool[name_index]);
  568.     u2 type_name_length = Constant_Utf8_info::Length(constant_pool[name_index]);
  569.  
  570.     int n;
  571.     for (n = type_name_length; n >= 0 && type_name[n] != U_SLASH; n--)
  572.         ;
  573.  
  574.     bool matched_package_names;
  575.     if (type -> ContainingPackage() -> PackageNameLength() == n)
  576.     {
  577.         wchar_t *package_name = type -> ContainingPackage() -> PackageName();
  578.         int i;
  579.         for (i = 0; i < n && package_name[i] == type_name[i]; i++)
  580.             ;
  581.         matched_package_names = (i == n);
  582.     }
  583.     else matched_package_names = (n < 0 && type -> ContainingPackage() == control.unnamed_package);
  584.  
  585.     if (! matched_package_names)
  586.     {
  587.         type -> SetSymbolTable(1); // this symbol table will only contain a default constructor
  588.         if (type != control.Object())
  589.             type -> super = (type == control.Throwable() ? control.Object() : control.Throwable());
  590.         type -> MarkBad();
  591.         AddDefaultConstructor(type);
  592.  
  593.         if (n < 0)
  594.             n = 0;
  595.         wchar_t *package_name = new wchar_t[n + 1];
  596.         for (int i = 0; i < n; i++)
  597.             package_name[i] = type_name[i];
  598.         package_name[n] = U_NULL;
  599.  
  600.         if (type -> ContainingPackage() == control.unnamed_package)
  601.              ReportSemError(SemanticError::TYPE_NOT_IN_UNNAMED_PACKAGE,
  602.                             tok,
  603.                             tok,
  604.                             type -> ExternalName(),
  605.                             type -> file_symbol -> directory_symbol -> PathSym() -> Name(),
  606.                             package_name);
  607.         else ReportSemError(SemanticError::TYPE_IN_WRONG_PACKAGE,
  608.                             tok,
  609.                             tok,
  610.                             type -> ExternalName(),
  611.                             type -> ContainingPackage() -> PackageName(),
  612.                             package_name);
  613.  
  614.         delete [] package_name;
  615.     }
  616.     else
  617.     {
  618.         if ((! type -> IsNested()) && (n < 0)) // An outermost type contained in the unnamed package?
  619.         {
  620.             TypeSymbol *old_type = (TypeSymbol *) control.unnamed_package_types.Image(type -> Identity());
  621.             if (! old_type)
  622.                 control.unnamed_package_types.AddElement(type);
  623.             else
  624.             {
  625.                 ReportSemError(SemanticError::DUPLICATE_TYPE_DECLARATION,
  626.                                tok,
  627.                                tok,
  628.                                type -> Name(),
  629.                                old_type -> FileLoc());
  630.             }
  631.         }
  632.  
  633.         //
  634.         // On systems such as NT and Win-95 that are not case-sensitive,
  635.         // we need to confirm that the type name specified matches the name
  636.         // in the class file.
  637.         //
  638.         assert(type_name_length - (n + 1) == type -> ExternalNameLength());
  639.  
  640.         int i;
  641.         for (i = 0; i < type -> ExternalNameLength(); i++)
  642.         {
  643.             if (type_name[(n + 1) + i] != type -> ExternalName()[i])
  644.                 break;
  645.         }
  646.         if (i < type -> ExternalNameLength())
  647.         {
  648.             wchar_t *name = new wchar_t[type_name_length + 1];
  649.             for (int k = 0; k < type_name_length; k++)
  650.                 name[k] = type_name[k];
  651.             name[type_name_length] = U_NULL;
  652.             ReportSemError(SemanticError::TYPE_NAME_MISMATCH,
  653.                            tok,
  654.                            tok,
  655.                            type -> ContainingPackage() -> PackageName(),
  656.                            type -> ExternalName(),
  657.                            name);
  658.             delete [] name;
  659.         }
  660.  
  661.         //
  662.         // ... Start doing real work !!!
  663.         //
  664.         if (! InRange(buffer, buffer_tail, 2))
  665.             return false;
  666.         u2 super_class = GetAndSkipU2(buffer);
  667.         if (super_class)
  668.         {
  669.             type -> super = GetClassPool(type, class_pool, constant_pool, super_class, tok);
  670.  
  671.             type -> outermost_type -> supertypes_closure -> AddElement(type -> super -> outermost_type);
  672.             type -> outermost_type -> supertypes_closure -> Union(*type -> super -> outermost_type -> supertypes_closure);
  673.         }
  674.  
  675.         if (! InRange(buffer, buffer_tail, 2))
  676.             return false;
  677.         for (int j = GetAndSkipU2(buffer); j > 0; j--)
  678.         {
  679.             if (! InRange(buffer, buffer_tail, 2))
  680.                 return false;
  681.             u2 interface_index = GetAndSkipU2(buffer);
  682.             type -> AddInterface(GetClassPool(type, class_pool, constant_pool, interface_index, tok));
  683.  
  684.             type -> outermost_type -> supertypes_closure -> AddElement(type -> super -> outermost_type);
  685.             type -> outermost_type -> supertypes_closure -> Union(*type -> super -> outermost_type -> supertypes_closure);
  686.         }
  687.  
  688.         //
  689.         // Read all the fields
  690.         //
  691.         if (! InRange(buffer, buffer_tail, 2))
  692.             return false;
  693.         u2 fields_count = GetAndSkipU2(buffer);
  694.         VariableSymbol **fields = new VariableSymbol*[fields_count];
  695.         for (int k = 0; k < fields_count; k++)
  696.         {
  697.             if (! InRange(buffer, buffer_tail, 6))
  698.                 return false;
  699.             u2 access_flags = GetAndSkipU2(buffer);
  700.             u2 name_index = GetAndSkipU2(buffer);
  701.             u2 descriptor_index = GetAndSkipU2(buffer);
  702.  
  703.             NameSymbol *name_symbol = control.ConvertUtf8ToUnicode(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  704.                                                                    Constant_Utf8_info::Length(constant_pool[name_index]));
  705.  
  706.             VariableSymbol *symbol = new VariableSymbol(name_symbol);
  707.             fields[k] = symbol;
  708.  
  709.             symbol -> SetOwner(type);
  710.             symbol -> MarkComplete();
  711.             symbol -> SetFlags(access_flags);
  712.             symbol -> SetSignatureString(Constant_Utf8_info::Bytes(constant_pool[descriptor_index]),
  713.                                          Constant_Utf8_info::Length(constant_pool[descriptor_index]));
  714.  
  715.             if (! InRange(buffer, buffer_tail, 2))
  716.                 return false;
  717.             int j = GetAndSkipU2(buffer);
  718.             for (; j > 0; j--)
  719.             {
  720.                 if (! InRange(buffer, buffer_tail, 2))
  721.                     return false;
  722.                 u2 name_index = GetAndSkipU2(buffer);
  723.  
  724.                 if (Constant_Utf8_info::Length(constant_pool[name_index]) == StringConstant::U8S_Synthetic_length &&
  725.                     memcmp(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  726.                            StringConstant::U8S_Synthetic, StringConstant::U8S_Synthetic_length * sizeof(char)) == 0)
  727.                 {
  728.                     symbol -> MarkSynthetic();
  729.                     if (! InRange(buffer, buffer_tail, 4))
  730.                         return false;
  731.                     Skip(buffer, 4); // u4 attribute_length() { return attribute_length_; }
  732.                                      // there is no info associated with a Synthetic attribute
  733.                     break; // If the field is synthetic, remaining attributes don't matter...
  734.                 }
  735.                 else if (Constant_Utf8_info::Length(constant_pool[name_index]) == StringConstant::U8S_Deprecated_length &&
  736.                          memcmp(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  737.                                 StringConstant::U8S_Deprecated, StringConstant::U8S_Deprecated_length * sizeof(char)) == 0)
  738.                 {
  739.                     symbol -> MarkDeprecated();
  740.                     if (! InRange(buffer, buffer_tail, 4))
  741.                         return false;
  742.                     Skip(buffer, 4); // u4 attribute_length() { return attribute_length_; }
  743.                                      // there is no info associated with a Deprecated attribute
  744.                 }
  745.                 else if (Constant_Utf8_info::Length(constant_pool[name_index]) == StringConstant::U8S_ConstantValue_length &&
  746.                          memcmp(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  747.                                 StringConstant::U8S_ConstantValue, StringConstant::U8S_ConstantValue_length * sizeof(char)) == 0)
  748.                 {
  749.                     Skip(buffer, 4); // u4 attribute_length;
  750.                     if (! InRange(buffer, buffer_tail, 2))
  751.                         return false;
  752.                     u2 constantvalue_index = GetAndSkipU2(buffer);
  753.  
  754.                     u1 tag = Cp_Info::Tag(constant_pool[constantvalue_index]);
  755.                     if (tag == Cp_Info::CONSTANT_Integer)
  756.                     {
  757.                         int value = Constant_Integer_info::Value(constant_pool[constantvalue_index]);
  758.                         symbol -> initial_value = control.int_pool.FindOrInsert(value);
  759.                     }
  760.                     else if (tag == Cp_Info::CONSTANT_Long)
  761.                     {
  762.                         LongInt value = Constant_Long_info::Value(constant_pool[constantvalue_index]);
  763.                         symbol -> initial_value = control.long_pool.FindOrInsert(value);
  764.                     }
  765.                     else if (tag == Cp_Info::CONSTANT_Float)
  766.                     {
  767.                         IEEEfloat value = Constant_Float_info::Value(constant_pool[constantvalue_index]);
  768.                         symbol -> initial_value = control.float_pool.FindOrInsert(value);
  769.                     }
  770.                     else if (tag == Cp_Info::CONSTANT_Double)
  771.                     {
  772.                         IEEEdouble value = Constant_Double_info::Value(constant_pool[constantvalue_index]);
  773.                         symbol -> initial_value = control.double_pool.FindOrInsert(value);
  774.                     }
  775.                     else if (tag == Cp_Info::CONSTANT_String)
  776.                     {
  777.                         u2 string_index = Constant_String_info::StringIndex(constant_pool[constantvalue_index]);
  778.                         u2 length = Constant_Utf8_info::Length(constant_pool[string_index]);
  779.                         char *value = Constant_Utf8_info::Bytes(constant_pool[string_index]);
  780.                         symbol -> initial_value = control.Utf8_pool.FindOrInsert(value, length);
  781.                     }
  782.                     else if (tag == Cp_Info::CONSTANT_Utf8)
  783.                     {
  784.                         u2 length = Constant_Utf8_info::Length(constant_pool[constantvalue_index]);
  785.                         char *value = Constant_Utf8_info::Bytes(constant_pool[constantvalue_index]);
  786.                         symbol -> initial_value = control.Utf8_pool.FindOrInsert(value, length);
  787.                     }
  788. else
  789. {
  790. fprintf(stderr, "%s%d%s", "chaos: Constant tag \"", (int) tag, "\" is an invalid tag !!!\n");
  791. fflush(stderr);
  792. }
  793.                 }
  794.                 else
  795.                 {
  796.                     if (! InRange(buffer, buffer_tail, 4))
  797.                         return false;
  798.                     Skip(buffer, GetAndSkipU4(buffer)); // u4 attribute_length() { return attribute_length_; }
  799.                                                         // u1 *info; /* info[attribute_length] */
  800.                 }
  801.             }
  802.  
  803.             //
  804.             // Skip remaining attributes
  805.             //
  806.             while (--j > 0)
  807.             {
  808.                 Skip(buffer, 2);                    // u2 name_index
  809.                 if (! InRange(buffer, buffer_tail, 4))
  810.                     return false;
  811.                 Skip(buffer, GetAndSkipU4(buffer)); // u4 attribute_length() { return attribute_length_; }
  812.                                                     // u1 *info; /* info[attribute_length] */
  813.             }
  814.         }
  815.  
  816.         //
  817.         // Read all the methods
  818.         //
  819.         if (! InRange(buffer, buffer_tail, 2))
  820.             return false;
  821.         u2 methods_count = GetAndSkipU2(buffer);
  822.         MethodSymbol **methods = new MethodSymbol*[methods_count];
  823.         for (int l = 0; l < methods_count; l++)
  824.         {
  825.             if (! InRange(buffer, buffer_tail, 6))
  826.                 return false;
  827.             u2 access_flags = GetAndSkipU2(buffer);
  828.             u2 name_index = GetAndSkipU2(buffer);
  829.             u2 descriptor_index = GetAndSkipU2(buffer);
  830.  
  831.             NameSymbol *name_symbol = control.ConvertUtf8ToUnicode(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  832.                                                                Constant_Utf8_info::Length(constant_pool[name_index]));
  833.  
  834.             if (! InRange(buffer, buffer_tail, 2))
  835.                 return false;
  836.             int j = GetAndSkipU2(buffer); // number of attributes
  837.  
  838.             if (name_symbol == control.clinit_name_symbol)
  839.             {
  840.                 methods[l] = NULL;
  841.                 j++; // see the loop (way) below that skips the remaining attributes
  842.             }
  843.             else
  844.             {
  845.                 MethodSymbol *method = new MethodSymbol(name_symbol);
  846.                 methods[l] = method;
  847.  
  848.                 method -> SetContainingType(type);
  849.                 method -> SetFlags(access_flags);
  850.  
  851.                 char *signature = Constant_Utf8_info::Bytes(constant_pool[descriptor_index]);
  852.                 int length = Constant_Utf8_info::Length(constant_pool[descriptor_index]);
  853.  
  854.                 method -> SetSignature(control.Utf8_pool.FindOrInsert(signature, length));
  855.  
  856.                 //
  857.                 // Read the exception that can be thrown by this method
  858.                 //
  859.                 for (; j > 0; j--)
  860.                 {
  861.                     if (! InRange(buffer, buffer_tail, 2))
  862.                         return false;
  863.                     u2 name_index = GetAndSkipU2(buffer);
  864.  
  865.                     if (Constant_Utf8_info::Length(constant_pool[name_index]) == StringConstant::U8S_Synthetic_length &&
  866.                         memcmp(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  867.                                StringConstant::U8S_Synthetic, StringConstant::U8S_Synthetic_length * sizeof(char)) == 0)
  868.                     {
  869.                         method -> MarkSynthetic();
  870.                         if (! InRange(buffer, buffer_tail, 4))
  871.                             return false;
  872.                         Skip(buffer, 4); // u4 attribute_length() { return attribute_length_; }
  873.                                          // there is no info associated with a Synthetic attribute
  874.                         break; // If the field is synthetic, remaining attributes don't matter...
  875.                     }
  876.                     else if (Constant_Utf8_info::Length(constant_pool[name_index]) == StringConstant::U8S_Deprecated_length &&
  877.                              memcmp(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  878.                                     StringConstant::U8S_Deprecated, StringConstant::U8S_Deprecated_length * sizeof(char)) == 0)
  879.                     {
  880.                         method -> MarkDeprecated();
  881.                         if (! InRange(buffer, buffer_tail, 4))
  882.                             return false;
  883.                         Skip(buffer, 4); // u4 attribute_length() { return attribute_length_; }
  884.                                          // there is no info associated with a Deprecated attribute
  885.                     }
  886.                     else if (Constant_Utf8_info::Length(constant_pool[name_index]) == StringConstant::U8S_Exceptions_length &&
  887.                              memcmp(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  888.                                     StringConstant::U8S_Exceptions, StringConstant::U8S_Exceptions_length * sizeof(char)) == 0)
  889.                     {
  890.                         Skip(buffer, 4); // attribute_length = GetAndSkipU4(buffer);
  891.                         if (! InRange(buffer, buffer_tail, 2))
  892.                             return false;
  893.                         for (int k = GetAndSkipU2(buffer); k > 0; k--)
  894.                         {
  895.                             if (! InRange(buffer, buffer_tail, 2))
  896.                                 return false;
  897.                             int index = GetAndSkipU2(buffer);
  898.                             u2 name_index = Constant_Class_info::NameIndex(constant_pool[index]);
  899.                             method -> AddThrowsSignature(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  900.                                                          Constant_Utf8_info::Length(constant_pool[name_index]));
  901.                         }
  902.                     }
  903.                     else
  904.                     {
  905.                         if (! InRange(buffer, buffer_tail, 4))
  906.                             return false;
  907.                         Skip(buffer, GetAndSkipU4(buffer)); // u4 attribute_length() { return attribute_length_; }
  908.                                                             // u1 *info; /* info[attribute_length] */
  909.                     }
  910.                 }
  911.             }
  912.  
  913.             //
  914.             // Skip remaining attributes
  915.             //
  916.             while (--j > 0)
  917.             {
  918.                 Skip(buffer, 2);                     // u2 name_index
  919.                 if (! InRange(buffer, buffer_tail, 4))
  920.                     return false;
  921.                 Skip(buffer, GetAndSkipU4(buffer)); // u4 attribute_length() { return attribute_length_; }
  922.                                                     // u1 *info; /* info[attribute_length] */
  923.             }
  924.         }
  925.  
  926.         //
  927.         // Process InnerClasses attributes
  928.         //
  929.         if (! InRange(buffer, buffer_tail, 2))
  930.             return false;
  931.         u2 attributes_count = GetAndSkipU2(buffer);
  932.         Tuple<u2> inner_name_indexes(8);
  933.         for (int a = 0; a < attributes_count; a++)
  934.         {
  935.             if (! InRange(buffer, buffer_tail, 2))
  936.                 return false;
  937.             u2 name_index = GetAndSkipU2(buffer);
  938.  
  939.             if (Constant_Utf8_info::Length(constant_pool[name_index]) == StringConstant::U8S_InnerClasses_length &&
  940.                 memcmp(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  941.                        StringConstant::U8S_InnerClasses, StringConstant::U8S_InnerClasses_length * sizeof(char)) == 0)
  942.             {
  943.                 Skip(buffer, 4); // attribute_length = GetAndSkipU4(buffer);
  944.                 if (! InRange(buffer, buffer_tail, 2))
  945.                     return false;
  946.                 for (int k = GetAndSkipU2(buffer); k > 0; k--)
  947.                 {
  948.                     if (! InRange(buffer, buffer_tail, 8))
  949.                         return false;
  950.                     u2 inner_class_info_index   = GetAndSkipU2(buffer);
  951.                     u2 outer_class_info_index   = GetAndSkipU2(buffer);
  952.                     u2 inner_name_index         = GetAndSkipU2(buffer);
  953.                     u2 inner_class_access_flags = GetAndSkipU2(buffer);
  954.  
  955.                     //
  956.                     // Recall that the untransformed access flag is the one specified
  957.                     // in the inner_class attribute. (See 1.1 document)
  958.                     //
  959.                     if (inner_class_info_index == this_class_index)
  960.                         type -> SetFlags(inner_class_access_flags);
  961.                     //
  962.                     // This guard statement is used to identify only inner classes that are
  963.                     // not anonymous classes and are immediately contained within this class.
  964.                     // Recall that an inner class may not be enclosed (directly on indirectly)
  965.                     // in another class with the same name. Therefore when outer_class_info_index
  966.                     // matches this_class_index they both refer to "this" class (that we are currently processing).
  967.                     //
  968.                     else if ((outer_class_info_index == this_class_index) &&
  969.                              (inner_class_info_index != 0) &&                  // an inner class
  970.                              (inner_name_index != 0))                          // not an anonymous class
  971.                     {
  972.                         //
  973.                         // When length is 0, the inner class in question is "this" class ?
  974.                         // the one we are currently reading ?
  975.                         //
  976.                         u2 length = Constant_Utf8_info::Length(constant_pool[inner_name_index]);
  977.                         if (length > 0)
  978.                             inner_name_indexes.Next() = inner_name_index;
  979.                     }
  980.                 }
  981.             }
  982.             else if (Constant_Utf8_info::Length(constant_pool[name_index]) == StringConstant::U8S_Deprecated_length &&
  983.                      memcmp(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  984.                             StringConstant::U8S_Deprecated, StringConstant::U8S_Deprecated_length * sizeof(char)) == 0)
  985.             {
  986.                 type -> MarkDeprecated();
  987.                 if (! InRange(buffer, buffer_tail, 4))
  988.                     return false;
  989.                 Skip(buffer, 4); // u4 attribute_length() { return attribute_length_; }
  990.                                  // there is no info associated with a Deprecated attribute
  991.             }
  992.             else
  993.             {
  994.                 if (! InRange(buffer, buffer_tail, 4))
  995.                     return false;
  996.                 Skip(buffer, GetAndSkipU4(buffer)); // u4 attribute_length() { return attribute_length_; }
  997.                                                     // u1 *info; /* info[attribute_length] */
  998.             }
  999.         }
  1000.  
  1001.         //
  1002.         // We now have enough information to make a good estimate for the size of the
  1003.         // symbol table we need for this class.
  1004.         //
  1005.         type -> SetSymbolTable(fields_count + methods_count + inner_name_indexes.Length());
  1006.  
  1007.         //
  1008.         //   . Read in all class files that are referenced in CONSTANT_Class
  1009.         //     structures in this class file.
  1010.         //
  1011.         //   . Read in all class files that are referenced in CONSTANT_NameAndType
  1012.         //     structures in this class file.
  1013.         //
  1014.         if (control.option.full_check && (control.option.unzip || (! type -> file_symbol -> IsZip())))
  1015.         {
  1016.             for (int h = Class_root; h != 0; h = next_pool_index[h])
  1017.                 GetClassPool(type, class_pool, constant_pool, h, tok);
  1018.  
  1019.             for (int j = NameAndType_root; j != 0; j = next_pool_index[j])
  1020.             {
  1021.                 u2 descriptor_index = Constant_NameAndType_info::DescriptorIndex(constant_pool[j]);
  1022.                 char *signature = Constant_Utf8_info::Bytes(constant_pool[descriptor_index]);
  1023.  
  1024.                 if (! class_pool[descriptor_index])
  1025.                 {
  1026.                     if (*signature != U_LEFT_PARENTHESIS)  // ')' indicates a field descriptor
  1027.                         class_pool[descriptor_index] = ProcessSignature(type,
  1028.                                                                         Constant_Utf8_info::Bytes(constant_pool[descriptor_index]),
  1029.                                                                         tok);
  1030.                     else // a method descriptor
  1031.                     {
  1032.                         signature++; // +1 to skip initial '('
  1033.                         while (*signature != U_RIGHT_PARENTHESIS)
  1034.                         {
  1035.                             char *str;
  1036.                             for (str = signature; *str == U_LEFT_BRACKET; str++)
  1037.                                 ;
  1038.  
  1039.                             if (*str == U_L)
  1040.                             {
  1041.                                 for (str++; *str != U_SEMICOLON; str++)
  1042.                                     ;
  1043.                             }
  1044.  
  1045.                             int len = str - signature + 1;
  1046.                             signature += len; // make signature point to next type
  1047.                         }
  1048.                         signature++; // skip L')'
  1049.  
  1050.                         class_pool[descriptor_index] = ProcessSignature(type, signature, tok); // save the return type in first spot
  1051.                     }
  1052.                 }
  1053.             }
  1054.  
  1055.             //
  1056.             // Process all the fields, then the methods, then the inner types.
  1057.             // Read in all the types associated with the signatures.
  1058.             //
  1059.             for (int k = 0; k < fields_count; k++)
  1060.             {
  1061.                 type -> InsertVariableSymbol(fields[k]);
  1062.                 fields[k] -> ProcessVariableSignature((Semantic *) this, tok);
  1063.             }
  1064.  
  1065.             for (int l = 0; l < methods_count; l++)
  1066.             {
  1067.                 if (methods[l])
  1068.                 {
  1069.                     MethodSymbol *method = type -> FindMethodSymbol(methods[l] -> name_symbol);
  1070.  
  1071.                     if (! method)
  1072.                     {
  1073.                          if (methods[l] -> name_symbol == control.init_name_symbol)
  1074.                               type -> InsertConstructorSymbol(methods[l]);
  1075.                          else type -> InsertMethodSymbol(methods[l]);
  1076.                     }
  1077.                     else type -> Overload(method, methods[l]);
  1078.                     methods[l] -> ProcessMethodSignature((Semantic *) this, tok);
  1079.                 }
  1080.             }
  1081.  
  1082.             for (int m = 0; m < inner_name_indexes.Length(); m++)
  1083.             {
  1084.                 u2 inner_name_index = inner_name_indexes[m];
  1085.                 type -> AddNestedTypeSignature(Constant_Utf8_info::Bytes(constant_pool[inner_name_index]),
  1086.                                                Constant_Utf8_info::Length(constant_pool[inner_name_index]));
  1087.             }
  1088.             type -> ProcessNestedTypeSignatures((Semantic *) this, tok);
  1089.         }
  1090.         else
  1091.         {
  1092.             //
  1093.             // Process all the fields, then the methods, then the inner types.
  1094.             //
  1095.             for (int k = 0; k < fields_count; k++)
  1096.                 type -> InsertVariableSymbol(fields[k]);
  1097.  
  1098.             for (int l = 0; l < methods_count; l++)
  1099.             {
  1100.                 if (methods[l])
  1101.                 {
  1102.                     MethodSymbol *method = type -> FindMethodSymbol(methods[l] -> name_symbol);
  1103.  
  1104.                     if (! method)
  1105.                     {
  1106.                          if (methods[l] -> name_symbol == control.init_name_symbol)
  1107.                               type -> InsertConstructorSymbol(methods[l]);
  1108.                          else type -> InsertMethodSymbol(methods[l]);
  1109.                     }
  1110.                     else type -> Overload(method, methods[l]);
  1111.                 }
  1112.             }
  1113.  
  1114.             for (int m = 0; m < inner_name_indexes.Length(); m++)
  1115.             {
  1116.                 u2 inner_name_index = inner_name_indexes[m];
  1117.                 type -> AddNestedTypeSignature(Constant_Utf8_info::Bytes(constant_pool[inner_name_index]),
  1118.                                                Constant_Utf8_info::Length(constant_pool[inner_name_index]));
  1119.             }
  1120.         }
  1121.  
  1122.         delete [] fields;
  1123.         delete [] methods;
  1124.  
  1125.         //
  1126.         // Release extra space. This is an optimization.
  1127.         //
  1128.         type -> CompressSpace();
  1129.     }
  1130.  
  1131.     delete [] next_pool_index;
  1132.     delete [] class_pool;
  1133.     delete [] constant_pool;
  1134.  
  1135.     return true;
  1136. }
  1137.  
  1138.  
  1139.